package com.longcai.service.fuyoupay.impl;


import java.util.Date;
import java.util.UUID;

import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.longcai.entity.payment.fuyou.request.ClyjFuyouRefund;
import com.longcai.fenzhuang.fuyou.BaseResponse;
import com.longcai.fenzhuang.fuyou.FuyouCommonPortMethod;
import com.longcai.mapper.fuyoupay.ClyjFuyouRefundMapper;
import com.longcai.service.fuyoupay.ClyjFuyouRefundService;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author LWK
 * @since 2019-04-16
 */
@Service
public class ClyjFuyouRefundServiceImpl extends ServiceImpl<ClyjFuyouRefundMapper, ClyjFuyouRefund> implements ClyjFuyouRefundService {

	@Override
	public ClyjFuyouRefund checkout(JSONObject params) {
		ClyjFuyouRefund cfr = new ClyjFuyouRefund();
		
		cfr.setId(UUID.randomUUID().toString().replace("-", ""));
		cfr.setMchntTxnNum(params.getString("mchntTxnNum"));
		cfr.setPaymentType(params.getString("paymentType"));
		cfr.setOrderType(params.getString("OrderType"));
		cfr.setAmt(params.getString("amt"));
		cfr.setRefundAmt(params.getString("amt"));
		cfr.setRefundReason("想退款");
		cfr.setRebates("");
		cfr.setRefundTime(new Date());
		FuyouCommonPortMethod fcpm = new FuyouCommonPortMethod();
		BaseResponse r = fcpm.refund(cfr);
		if (r!=null&r.getRespCode().equals("0000")) {
			return cfr;
		}
		
		return null;
	}

}
